package fr.LesLoutresSauvages.laloutresportive.util;

import org.json.JSONException;
import org.json.JSONObject;

public class LiveCreation implements JsonConvertible {

	private String nomCommentateur;
	private String nom;
	private String equipe1;
	private String equipe2;
	private String latitude;
	private String longitude;
	private int competitionId;
	private int departementId;
	private String shortDescription;
	private String longDescription;
	private String debut;
	private int sportId;

	public LiveCreation() {
		super();
		this.nomCommentateur = "";
		this.nom = "";
		this.equipe1 = "";
		this.equipe2 = "";
		this.latitude = "";
		this.longitude = "";
		this.competitionId = 0;
		this.departementId = 0;
		this.shortDescription = "";
		this.longDescription = "";
		this.debut = "";
		this.sportId = 0;
	}

	public LiveCreation(String nomCommentateur, String nom, String equipe1,
			String equipe2, String latitude, String longitude,
			int competitionId, int departementId, String shortDescription,
			String longDescription, String debut, int sportId) {
		super();
		this.nomCommentateur = nomCommentateur;
		this.nom = nom;
		this.equipe1 = equipe1;
		this.equipe2 = equipe2;
		this.latitude = latitude;
		this.longitude = longitude;
		this.competitionId = competitionId;
		this.departementId = departementId;
		this.shortDescription = shortDescription;
		this.longDescription = longDescription;
		this.debut = debut;
		this.sportId = sportId;
	}

	public void setAll(String nomCommentateur, String nom, String equipe1,
			String equipe2, String latitude, String longitude,
			int competitionId, int departementId, String shortDescription,
			String longDescription, String debut, int sportId) {
		this.nomCommentateur = nomCommentateur;
		this.nom = nom;
		this.equipe1 = equipe1;
		this.equipe2 = equipe2;
		this.latitude = latitude;
		this.longitude = longitude;
		this.competitionId = competitionId;
		this.departementId = departementId;
		this.shortDescription = shortDescription;
		this.longDescription = longDescription;
		this.debut = debut;
		this.sportId = sportId;
	}

	public String getNomCommentateur() {
		return nomCommentateur;
	}

	public void setNomCommentateur(String nomCommentateur) {
		this.nomCommentateur = nomCommentateur;
	}

	public String getNom() {
		return nom;
	}

	public void setNom(String nom) {
		this.nom = nom;
	}

	public String getEquipe1() {
		return equipe1;
	}

	public void setEquipe1(String equipe1) {
		this.equipe1 = equipe1;
	}

	public String getEquipe2() {
		return equipe2;
	}

	public void setEquipe2(String equipe2) {
		this.equipe2 = equipe2;
	}

	public String getLatitude() {
		return latitude;
	}

	public void setLatitude(String latitude) {
		this.latitude = latitude;
	}

	public String getLongitude() {
		return longitude;
	}

	public void setLongitude(String longitude) {
		this.longitude = longitude;
	}

	public int getCompetitionId() {
		return competitionId;
	}

	public void setCompetitionId(int competitionId) {
		this.competitionId = competitionId;
	}

	public int getDepartementId() {
		return departementId;
	}

	public void setDepartementId(int departementId) {
		this.departementId = departementId;
	}

	public String getShortDescription() {
		return shortDescription;
	}

	public void setShortDescription(String shortDescription) {
		this.shortDescription = shortDescription;
	}

	public String getLongDescription() {
		return longDescription;
	}

	public void setLongDescription(String longDescription) {
		this.longDescription = longDescription;
	}

	public String getDebut() {
		return debut;
	}

	public void setDebut(String debut) {
		this.debut = debut;
	}

	public int getSportId() {
		return sportId;
	}

	public void setSportId(int sportId) {
		this.sportId = sportId;
	}

	@Override
	public String toJSON() {
		JSONObject json = new JSONObject();
		try {
			json.put("commentateur", this.getNomCommentateur());
			json.put("nom", this.getNom());
			json.put("equipe1", this.getEquipe1());
			json.put("equipe2", this.getEquipe2());
			json.put("competitionId", this.getCompetitionId());
			json.put("departementId", this.getDepartementId());
			json.put("latitude", this.getLatitude());
			json.put("longitude", this.getLongitude());
			json.put("shortDescription", this.getShortDescription());
			json.put("longDescription", this.getLongDescription());
			json.put("debut", this.getDebut());
			json.put("sportId", this.getSportId());
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return json.toString();
	}

	@Override
	public void fromJSON(String str) {
		try {
			JSONObject json = new JSONObject(str);
			this.setNomCommentateur(json.getString("commentateur"));
			this.setNom(json.getString("nom"));
			this.setEquipe1(json.getString("equipe1"));
			this.setEquipe2(json.getString("equipe2"));
			this.setCompetitionId(json.getInt("competitionId"));
			this.setDepartementId(json.getInt("departementId"));
			this.setLatitude(json.getString("latitude"));
			this.setLongitude(json.getString("longitude"));
			this.setShortDescription(json.getString("shortDescription"));
			this.setLongDescription(json.getString("longDescription"));
			this.setDebut(json.getString("debut"));
			this.setSportId(json.getInt("sportId"));
		} catch (JSONException e) {
			e.printStackTrace();
		}
	}
}